print('creating create structure mesh')
import numpy as np
from define_problem_space_parameters import icoat_pool,mapC2M_pool
from define_problem_space_parameters import material_types
from initialize_fdtd_material_grid import material_3d_space
from get_node_indices import get_node_indices
from initialize_fdtd_material_grid import material_3d_space
from calculate_domain_size import bricks,fdtd_domain
from environment_pool import mesh_x0_pool,mesh_y0_pool,mesh_z0_pool,mesh_type_pool
if(mesh_type_pool>0):
    from define_geometry import icoat_mat
    icoat = icoat_pool
    mapC2M = mapC2M_pool
    nx0,ny0,nz0 = icoat_pool.shape
    dx = fdtd_domain["dx"]
    dy = fdtd_domain["dy"]
    dz = fdtd_domain["dz"]
    structure_obj = {
        "min_x":mesh_x0_pool,
        "min_y":mesh_y0_pool,
        "min_z":mesh_z0_pool,
        "max_x":mesh_x0_pool+dx*nx0,
        "max_y":mesh_y0_pool+dy*ny0,
        "max_z":mesh_z0_pool+dz*nz0
    }
from environment_pool import mesh_type_pool
if(mesh_type_pool>0):
    # convert brick end coordinates to node indices
    #TODO:此处定义了sampled_electric_fields序号和计算下标间的映射
    ni = get_node_indices(structure_obj, fdtd_domain)
    is_ = ni["is"]
    js = ni["js"]
    ks = ni["ks"]
    ie = ni["ie"]
    je = ni["je"]
    ke = ni["ke"]
    # assign material type of the brick to the cells
    material_3d_space[is_:ie, js:je, ks:ke]  = icoat_mat
# print(np.sum(np.abs(material_3d_space-1)))
# exit(-1)